from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage

# 定位器
cpllect_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("收藏")')
search_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/search_edit_text")')
all_recipe_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("所有菜谱")')
search_locator_01=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("搜索")')
find_hot_recipe_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/collect_recipe_find_hot_recipe_btn")')
common_first_text_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("极简·古法｜酱牛肉·卤牛肉·牛腱子｜卡卡爸·不藏私")')
recipe_bto_nav_bar_collect_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/recipe_bto_nav_bar_collect")')
skip_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("跳过")')
common_first_text_locator_01=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/common_first_text")')
common_end_text_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("2701-2727")')
click_common_end_recipe=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/round_hollow").instance(5)')
input_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/recipe_bto_nav_bar_comment_btn")')
input_locator_01=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/eidt_comment_content")')
red_heart_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("❤")')
send_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/tv_comment_publish_btn")')


class CpllectPage(BasePage):

    def click_skip(self):
        """
        点击跳过
        :return:
        """
        self.find_element(skip_locator).click()

    def click_cpllect(self):
        """
        点击收藏
        :return:
        """
        self.find_element(cpllect_locator).click()
    def click_all_recipe(self):
        """
        点击所有菜谱
        :return:
        """
        self.find_element(all_recipe_locator).click()


    def click_search(self):
        """
        点击搜索框
        :return:
        """
        self.find_element(search_locator).click()

    def input_search(self):
        """
        输入搜索内容
        :return:
        """
        self.find_element(search_locator).send_keys("酱牛肉")

    def click_search_01(self):
        """
        点击搜索
        :return:
        """
        self.find_element(search_locator_01).click()


    def click_find_hot_recipe(self):
        """
        点击发现热菜
        :return:
        """
        self.find_element(find_hot_recipe_locator).click()

    def click_common_first_text(self):
        """
        点击第一个热菜
        :return:
        """
        self.find_element(common_first_text_locator).click()

    def swipe_recipe(self):
        """
        滑动
        :return:
        """
        self.driver.swipe(950, 700, 125, 700, 2000)

    def click_common_end_text(self):
        """
        点击最后排名的热菜
        :return:
        """
        self.find_element(common_end_text_locator).click()

    def click_common_end_recipe(self):
        """
        点击最后一个热菜
        :return:
        """
        self.find_element(click_common_end_recipe).click()

    def click_recipe_bto_nav_bar_collect(self):
        """
        点击收藏按钮
        :return:
        """
        self.find_element(recipe_bto_nav_bar_collect_locator).click()

    def click_common_first_text_01(self):
        """
        点击第一个热菜
        :return:
        """
        self.find_element(common_first_text_locator_01).click()

    def click_recipe_bto_nav_bar_collect_01(self):
        """
        点击取消收藏按钮
        :return:
        """
        self.find_element(recipe_bto_nav_bar_collect_locator)

    def input_text(self):
        """
        输入评论内容
        :return:
        """
        self.find_element(input_locator_01).send_keys("我是测试")

    def click_input(self):
        """
        点击评论输入框
        :return:
        """
        self.find_element(input_locator).click()

    def click_red_heart(self):
        """
        点击小红心
        :return:
        """
        self.find_element(red_heart_locator).click()

    def click_send(self):
        """
        点击发送按钮
        :return:
        """
        self.find_element(send_locator).click()